package mya.mes.mdc.mqtt;


import mya.mes.mdc.share.mqttread.MqttMsgProcessor;
import mya.mes.mdc.share.vo.mqtt.MqttMsgReceived;
import mya.mes.mdc.share.vo.mqtt.MsgProcessTaskResult;

import java.util.concurrent.Callable;

public class MsgProcessTask implements Callable<MsgProcessTaskResult> {

    private MqttMsgReceived mqttPayload;

    private MqttMsgProcessor mqttMsgProcessor;

    public MsgProcessTask(MqttMsgReceived mqttPayload, MqttMsgProcessor mqttMsgProcessor) {
        this.mqttPayload = mqttPayload;
        this.mqttMsgProcessor = mqttMsgProcessor;
    }

    @Override
    public MsgProcessTaskResult call() throws Exception {
        try {
            mqttMsgProcessor.mqttReceive(mqttPayload);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new MsgProcessTaskResult();
    }

}
